const postorder = (root) => {
  let ans = []
  if(root !== null) {
    const s1 = []
    const s2 = []
    s1.push(root)
    while(s1.length > 0) {
      root = s1.pop()
      s2.push(root)
      if(root.left) {
        s1.push(root.left)
      }
      if(root.right) {
        s1.push(root.right)
      }
    }
    while(s2.length > 0) {
      let node = s2.pop()
      ans.push(node.val)
    }
  }
  return ans
}